﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using com.tiyma.common;

namespace com.tiyma.web
{
    public partial class ajaxUtil : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string opName = Request["opName"];

            string result = string.Empty;
            
            string procName = Request["procName"];

            bool t_ret = false;

            string t_server_result = string.Empty;
            string t_js = string.Empty;
            switch (opName)
            {
                case "ExcuteScript":
                    t_server_result = PageUtil.ExcuteScript(procName, Request["script"], out t_ret,out t_js);
                    result = this.ToJSON(t_server_result, t_ret, t_js);
                    break;
               
            }
            
            Response.Clear();
            Response.Write(result);
            Response.End();
        }

   

        private string ToJSON(string singleData,bool i_ret,string i_js)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("{value:");
            sb.Append("\"");
            sb.Append(singleData).Append("\"").AppendFormat(",result:\"{0}\"",i_ret).AppendFormat(",js:\"{0}\"",i_js).Append("}");
           
            return sb.ToString();
        }
    }
}
